package com.x.reader.service;

import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import com.x.reader.dao.BannerDao;
import com.x.reader.model.App;
import com.x.reader.model.Banner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class BannerService extends BaseService {

    @Autowired
    private BannerDao bannerDao;

    public Banner insertBanner(Banner banner) {
        try {
            return this.insert(banner);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public void updateBanner(Banner banner) {
        try {
            this.update(banner);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public int deleteBanner(Banner banner) {
        try {
            return this.delete(banner);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public List<Banner> selectBannerList(Banner banner) {
        try {
            return bannerDao.selectBannerList(banner);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

}
